#!/usr/bin/env python

import wx

class Channel(wx.BoxSizer):
    '''ToolBar class
    
    @author Julot <andy.julot@gmail.com>
    @since Thursday, February 02, 2012. 11:00 PM'''
    
    def __init__(self, parent, title, value):
        super(Channel, self).__init__(wx.VERTICAL)
        self.realize(parent, title, value)
        self.bind()
        
    def realize(self, parent, title, value):
        self._title = wx.StaticText(parent, label=title,
                                    style=wx.ST_NO_AUTORESIZE | wx.ALIGN_CENTER)
        self.Add(self._title, flag=wx.EXPAND)
        
        style = wx.SL_VERTICAL | wx.SL_INVERSE
        self._gain = wx.Slider(parent, value=value, minValue=1, maxValue=10,  
                              size=(-1, 200), style=style)
        self.Add(self._gain, 1)
        
        self._value = wx.StaticText(parent, label='%s' % value,
                                    style=wx.ST_NO_AUTORESIZE | wx.ALIGN_CENTER)
        self.Add(self._value, flag=wx.EXPAND)
        
    def bind(self):
        self._gain.Bind(wx.EVT_SCROLL, self._onScroll)
        
    def _onScroll(self, event):
        self._value.Label = '%s' % event.Position
        event.Skip()
        
    @property
    def gain(self):
        return self._gain.Value
    
    @gain.setter
    def gain(self, value):
        self._gain.Value = value
        self._value.Label = '%s' % value